<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Boss extends Boss_Controller {

	
	public function index()
	{
		$this->load->view('boss/index');
	}
	
	public function  login(){
		$this->load->view('boss/login');
	}
	
	public function login_post(){
		$name = isset($_POST['name'])?$_POST['name']:'';
		$pass = isset($_POST['pass'])?$_POST['pass']:'';
		$this->load->model("Manager_Model");
		$manager = $this->Manager_Model->get_one("(name='".$name."' or mobile='".$name."') and password='".md5($pass)."'");
		if($manager){
			$_SESSION['manager']=$manager;
			echo json_encode(array("success"=>1,"msg"=>"登录成功"));
			exit(0);
		}else{
			echo json_encode(array("success"=>0,"msg"=>"账号或密码错误"));
			exit(0);
		}	
	}
	
	public function login_out(){
		$this->load->helper('cookie');
		$_SESSION['manager']='';
		$this->index();
	}
	
	public function article_list(){
		$page = isset($_GET['page'])?$_GET['page']:1;
		$this->load->model("Siye_Model");
		$article_list = $this->Siye_Model->get_list_ad("url like '%&%' ","*"," id desc ",($page-1)*20,20);
		$total = $this->Siye_Model->getTotal("url like '%&%' ");
		$this->load->view('boss/article_list',array("article_list"=>$article_list,"page"=>$page,"page_size"=>ceil($total/20)));
	}
	
	public function edit_article(){
		$id = isset($_GET['id'])?$_GET['id']:0;
		if(!$id){
			echo "请选择数据";
		}
		$this->load->model("Siye_Model");
		$article_info = $this->Siye_Model->get_one("id=".$id);
		$this->load->view('boss/article_edit',array("article_info"=>$article_info));
	}
	
	public function edit_article_post(){
		$id = isset($_POST['id'])?$_POST['id']:'';
		$content = isset($_POST['content'])?$_POST['content']:'';
		$project_style = isset($_POST['project_style'])?$_POST['project_style']:'';
		$about = isset($_POST['about'])?$_POST['about']:'';
		$title =isset( $_POST['title'])?$_POST['title']:'';
		$this->load->model("Siye_Model");
		$string = $_FILES['file']['name'];
		$array = explode('.',$string);
		$ext=end($array);
		$url="upload/fengm/" . time().rand(10000, 9999).".".$ext;
		move_uploaded_file($_FILES["file"]["tmp_name"],$url);
		$arr = array(
				"content"=>$content,
				"project_style"=>$project_style,
				"about"=>$about,
				"title"=>$title,
				"fengmian_pic"=>"/".$url
		);
		$this->Siye_Model->update($arr,'id='.$id);
		$article_info = $this->Siye_Model->get_one("id=".$id);
		$this->load->view('boss/article_edit',array("article_info"=>$article_info));
	}
	
	public function user_info(){
	
		$this->load->view("boss/user_info");
	}
	
	public function edit_user(){
	
		$this->load->view("boss/edit_user");
	}
	
	public function edit_user_post(){
		$name = isset($_POST['name'])?$_POST['name']:'';
		$password = isset($_POST['password'])?$_POST['password']:'';
		$password2 = isset($_POST['password2'])?$_POST['password2']:'';
		$old_password = isset($_POST['old_password'])?$_POST['old_password']:'';
		if(!$password || !$password2 || !$old_password){
			$this->load->view("boss/edit_user",array("msg"=>"密码不能为空"));
			return;
		}
		if($password!=$password2){
			$this->load->view("boss/edit_user",array("msg"=>"两次密码不一致"));
			return;
		}
		if(md5($old_password)!=$_SESSION['manager']['password']){
			$this->load->view("boss/edit_user",array("msg"=>"您输入的密码不对"));
			return;
		}
		$data = array(
				"name"=>$name,
				"password"=>md5($password)
		);
		$_SESSION['manager']['name']=$name;
		$_SESSION['manager']['password']=md5($password);
		$this->load->model("Manager_Model");
		$flag = $this->Manager_Model->update($data,"id=".$_SESSION['manager']['id']);
		if($flag){
			$this->load->view("boss/user_info");
			return;
		}else{
			$this->load->view("boss/edit_user",array("msg"=>"修改信息失败"));
			return;
		}
	
	}
	
	public function articlelist(){
		$page = isset($_GET['page'])?$_GET['page']:1;
		$project_style = isset($_GET['project_style'])?$_GET['project_style']:'';
		$title = isset($_GET['title'])?$_GET['title']:'';
		$this->load->model("Article_Model");
		$where="deleted=0";
		if($project_style){
			$where=$where." and project_style=$project_style";
		}
		if($title){
			$where=$where." and title like '%".$title."%'";
		}
		$article_list = $this->Article_Model->get_list_ad($where,"*"," id desc ",($page-1)*20,20);
		$total = $this->Article_Model->getTotal($where);
		$this->load->view('boss/articlelist',array("article_list"=>$article_list,"page"=>$page,"page_size"=>ceil($total/20),
				"project_style"=>$project_style,
				"title"=>$title
		));
	}
	
	public function editarticle(){
		$id = isset($_GET['id'])?$_GET['id']:0;
		if(!$id){
			echo "请选择数据";
		}
		$this->load->model("Article_Model");
		$article_info = $this->Article_Model->get_one("id=".$id);
		$this->load->view('boss/articleedit',array("article_info"=>$article_info));
	}
	
	public function addarticle(){
		$this->load->view('boss/articleadd');
	}
	
	public function edit_articlepost(){
		$id = isset($_POST['id'])?$_POST['id']:'';
		$content = isset($_POST['content'])?$_POST['content']:'';
		$project_style = isset($_POST['project_style'])?$_POST['project_style']:'';
		$about = isset($_POST['about'])?$_POST['about']:'';
		$title = isset($_POST['title'])?$_POST['title']:'';
		$this->load->model("Article_Model");
		$string = $_FILES['file']['name'];
		$style = $_POST['style']?$_POST['style']:0;
		$type_id = $_POST['type_id']?$_POST['type_id']:0;
		$array = explode('.',$string);
		$ext=end($array);
		$url="";
		if($_FILES["file"]["tmp_name"]){
			$url="upload/fengm/" . time().rand(10000, 9999).".".$ext;
			move_uploaded_file($_FILES["file"]["tmp_name"],$url);
		}
		$arr = array(
				"content"=>$content,
				"project_style"=>$project_style,
				"about"=>$about,
				"title"=>$title,
				'style'=>$style,
				"type_id"=>$type_id,
		);
		if($url){
			$arr["fengm_pic"]="/".$url;
		}
		$this->Article_Model->update($arr,'id='.$id);
		$article_info = $this->Article_Model->get_one("id=".$id);
		$this->load->view('boss/articleedit',array("article_info"=>$article_info));
	}
	
	public function add_articlepost(){
		$content = isset($_POST['content'])?$_POST['content']:'';
		$project_style = isset($_POST['project_style'])?$_POST['project_style']:'';
		$about = isset($_POST['about'])?$_POST['about']:'';
		$title = isset($_POST['title'])?$_POST['title']:'';
		$style = isset($_POST['style'])?$_POST['style']:0;
		$type_id = isset($_POST['type_id'])?$_POST['type_id']:0;
		$this->load->model("Article_Model");
		$string = $_FILES['file']['name'];
		$array = explode('.',$string);
		$ext=end($array);
		$url="";
		if($_FILES["file"]["tmp_name"]){
			$url="upload/fengm/" . time().rand(10000, 9999).".".$ext;
			move_uploaded_file($_FILES["file"]["tmp_name"],$url);
		}
		$arr = array(
				"content"=>$content,
				"project_style"=>$project_style,
				"about"=>$about,
				"title"=>$title,
				'style'=>$style,
				"type_id"=>$type_id,
		);
		if($url){
			$arr["fengm_pic"]="/".$url;
		}
		$id = $this->Article_Model->add($arr);
		$article_info = $this->Article_Model->get_one("id=".$id);
		$this->load->view('boss/articleedit',array("article_info"=>$article_info));
	}
	
	public function deletearticle(){
		$id = isset($_GET['id'])?$_GET['id']:'';
		$this->load->model("Article_Model");
		$arr = array(
				"deleted"=>1,
		);
		$this->Article_Model->update($arr,'id='.$id);
		$page =1;
		$project_style = $_GET['project_style']?$_GET['project_style']:'';
		$title = $_GET['title']?$_GET['title']:'';
		$where="deleted=0";
		if($project_style){
			$where=$where." and project_style=$project_style";
		}
		if($title){
			$where=$where." and title like '%".$title."%'";
		}
		$article_list = $this->Article_Model->get_list_ad($where,"*"," id desc ",($page-1)*20,20);
		$total = $this->Article_Model->getTotal($where);
		$this->load->view('boss/articlelist',array("article_list"=>$article_list,"page"=>$page,"page_size"=>ceil($total/20),
				"project_style"=>$project_style,
				"title"=>$title
		));
	}
	
	public function gd_pic_list(){
		$this->load->model("Gdad_Model");
		$type = isset($_GET['type'])?$_GET['type']:'';
		$page = isset($_GET['page'])?$_GET['page']:1;
		$where="deleted=0";
		if($type){
			$where=$where." and type=".$type;
		}
		$list = $this->Gdad_Model->get_list_p($where,"*"," id desc ",($page-1)*20,20);
		$total = $this->Gdad_Model->getTotal($where);
		$this->load->view('boss/gd_pic_list',array("list"=>$list,"type"=>$type,"page"=>$page,"page_size"=>ceil($total/20)));
	}
	
	public function gd_pic_add(){
		$this->load->view('boss/gd_pic_add');
	}
	
	public function gd_pic_addpost(){
		$url = isset($_POST['url'])?$_POST['url']:'';
		$order_num = isset($_POST['order_num'])?$_POST['order_num']:'';
		$type = isset($_POST['type'])?$_POST['type']:'';
		$title = isset($_POST['title'])?$_POST['title']:'';
		$this->load->model("Article_Model");
		$string = $_FILES['file']['name'];
		$array = explode('.',$string);
		$ext=end($array);
		$url="";
		if($_FILES["file"]["tmp_name"]){
			$url="upload/fengm/" . time().rand(10000, 9999).".".$ext;
			move_uploaded_file($_FILES["file"]["tmp_name"],$url);
		}
		$arr = array(
				"url"=>$url,
				"order_num"=>$order_num,
				"type"=>$type,
				"title"=>$title,
		);
		if($url){
			$arr["pic"]="/".$url;
		}
		$this->load->model("Gdad_Model");
		$id = $this->Gdad_Model->add($arr);
		$article_info = $this->Gdad_Model->get_one("id=".$id);
		header('Location: /boss/gd_pic_list?page=1&type=');
		exit;
	}
	
	public function projectlist(){
		$page = isset($_GET['page'])?$_GET['page']:1;
		$project_style = isset($_GET['project_style'])?$_GET['project_style']:'';
		$title = isset($_GET['title'])?$_GET['title']:'';
		$this->load->model("Project_Model");
		$where="deleted=0";
		if($project_style){
			$where=$where." and project_style=$project_style";
		}
		if($title){
			$where=$where." and little_name like '%".$title."%'";
		}
		$article_list = $this->Project_Model->get_list_ad($where,"*"," id desc ",($page-1)*20,20);
		$total = $this->Project_Model->getTotal($where);
		$this->load->view('boss/projectlist',array("article_list"=>$article_list,"page"=>$page,"page_size"=>ceil($total/20),
				"project_style"=>$project_style,
				"title"=>$title
		));
	}
	
	public function deleteproject(){
		$id = isset($_GET['id'])?$_GET['id']:'';
		$this->load->model("Project_Model");
		$arr = array(
				"deleted"=>1,
		);
		$this->Project_Model->update($arr,'id='.$id);
		$page = 1;
		$project_style = $_GET['project_style']?$_GET['project_style']:'';
		$title = $_GET['title']?$_GET['title']:'';
		$where="deleted=0";
		if($project_style){
			$where=$where." and project_style=$project_style";
		}
		if($title){
			$where=$where." and little_name like '%".$title."%'";
		}
		$article_list = $this->Project_Model->get_list_ad($where,"*"," id desc ",($page-1)*20,20);
		$total = $this->Project_Model->getTotal($where);
		$this->load->view('boss/projectlist',array("article_list"=>$article_list,"page"=>$page,"page_size"=>ceil($total/20),
				"project_style"=>$project_style,
				"title"=>$title
		));
	}
	
	public function addproject(){
		$this->load->view('boss/projectadd');
	}
	
	public function upload_img(){
		print_r(file_get_contents('php://input'));
		$string = $_FILES['upfile']['name'];
		$array = explode('.',$string);
		$ext=end($array);
		$url="";
		if($_FILES["file"]["tmp_name"]){
			$url="upload/fengm/" . time().rand(10000, 9999).".".$ext;
			move_uploaded_file($_FILES["file"]["tmp_name"],$url);
		}
		echo $url;
		exit(0);
	}
	public function add_projectpost(){
		/* print_r($_REQUEST);
		print_r($_REQUEST['little_name']); */
		$little_name = $_POST['little_name']?$_POST['little_name']:'';
		$project_style = $_POST['project_style']?$_POST['project_style']:'';
		$real_name = $_POST['real_name']?$_POST['real_name']:'';
		$gu_quan_daima = $_POST['gu_quan_daima']?$_POST['gu_quan_daima']:'';
		$hang_ye = $_POST['hang_ye']?$_POST['hang_ye']:'';
		$di_yu = $_POST['di_yu']?$_POST['di_yu']:'';
		$project_state = $_POST['project_state']?$_POST['project_state']:'';
		$tou_zi_type = $_POST['tou_zi_type']?$_POST['tou_zi_type']:'';
		$project_about = $_POST['project_about']?$_POST['project_about']:'';
		$project_advantage = $_POST['project_advantage']?$_POST['project_advantage']:'';
		$project_highlights = $_POST['project_highlights']?$_POST['project_highlights']:'';
		$team_worker = $_POST['team_worker']?$_POST['team_worker']:'';
		$is_youxuan = $_POST['is_youxuan']?$_POST['is_youxuan']:'';
		$touzi_qx = $_POST['touzi_qx']?$_POST['touzi_qx']:'';
		$qitou_zj = $_POST['qitou_zj']?$_POST['qitou_zj']:'';
		$company_about = $_POST['company_about']?$_POST['company_about']:'';
		
		
		$this->load->model("Project_Model");
		$string = $_FILES['upfile']['name'];
		$array = explode('.',$string);
		$ext=end($array);
		$url="";
		if($_FILES["upfile"]["tmp_name"]){
			$url="upload/fengm/" . time().rand(10000, 9999).".".$ext;
			move_uploaded_file($_FILES["upfile"]["tmp_name"],$url);
		}
		$arr = array(
				"little_name"=>$little_name,
				"project_style"=>$project_style,
				"real_name"=>$real_name,
				"gu_quan_daima"=>$gu_quan_daima,
				"hang_ye"=>$hang_ye,
				"di_yu"=>$di_yu,
				"project_state"=>$project_state,
				"tou_zi_type"=>$tou_zi_type,
				"project_about"=>$project_about,
				"project_advantage"=>$project_advantage,
				"project_highlights"=>$project_highlights,
				"team_worker"=>$team_worker,
				"is_youxuan"=>$is_youxuan,
				"touzi_qx"=>$touzi_qx,
				"qitou_zj"=>$qitou_zj,
				"company_about"=>$company_about,
		);
		if($url){
			$arr["img"]="/".$url;
		}
		$id = $this->Project_Model->add($arr);
		$project_info = $this->Project_Model->get_one("id=".$id);
		$this->load->view('boss/projectedit',array("project_info"=>$project_info));
	}
	
	public function projectedit(){
		$id = isset($_GET['id'])?$_GET['id']:0;
		$this->load->model("Project_Model");
		$project_info = $this->Project_Model->get_one("id=".$id);
		$this->load->view('boss/projectedit',array("project_info"=>$project_info));
	}
	
	public function edit_projectpost(){
		$id = isset($_POST['id'])?$_POST['id']:'';
		$little_name = isset($_POST['little_name'])?$_POST['little_name']:'';
		$project_style = isset($_POST['project_style'])?$_POST['project_style']:'';
		$real_name = isset($_POST['real_name'])?$_POST['real_name']:'';
		$gu_quan_daima = isset($_POST['gu_quan_daima'])?$_POST['gu_quan_daima']:'';
		$hang_ye = isset($_POST['hang_ye'])?$_POST['hang_ye']:'';
		$di_yu = isset($_POST['di_yu'])?$_POST['di_yu']:'';
		$project_state = isset($_POST['project_state'])?$_POST['project_state']:'';
		$tou_zi_type = isset($_POST['tou_zi_type'])?$_POST['tou_zi_type']:'';
		$project_about = isset($_POST['project_about'])?$_POST['project_about']:'';
		$project_advantage = isset($_POST['project_advantage'])?$_POST['project_advantage']:'';
		$project_highlights = isset($_POST['project_highlights'])?$_POST['project_highlights']:'';
		$team_worker = isset($_POST['team_worker'])?$_POST['team_worker']:'';
		$is_youxuan = isset($_POST['is_youxuan'])?$_POST['is_youxuan']:'';
		$touzi_qx = isset($_POST['touzi_qx'])?$_POST['touzi_qx']:'';
		$qitou_zj = isset($_POST['qitou_zj'])?$_POST['qitou_zj']:'';
		$company_about = isset($_POST['company_about'])?$_POST['company_about']:'';
	
	
		$this->load->model("Project_Model");
		$string = $_FILES['file']['name'];
		$array = explode('.',$string);
		$ext=end($array);
		$url="";
		if($_FILES["file"]["tmp_name"]){
			$url="upload/fengm/" . time().rand(10000, 9999).".".$ext;
			move_uploaded_file($_FILES["file"]["tmp_name"],$url);
		}
		$arr = array(
				"little_name"=>$little_name,
				"project_style"=>$project_style,
				"real_name"=>$real_name,
				"gu_quan_daima"=>$gu_quan_daima,
				"hang_ye"=>$hang_ye,
				"di_yu"=>$di_yu,
				"project_state"=>$project_state,
				"tou_zi_type"=>$tou_zi_type,
				"project_about"=>$project_about,
				"project_advantage"=>$project_advantage,
				"project_highlights"=>$project_highlights,
				"team_worker"=>$team_worker,
				"is_youxuan"=>$is_youxuan,
				"touzi_qx"=>$touzi_qx,
				"qitou_zj"=>$qitou_zj,
				"company_about"=>$company_about,
		);
		if($url){
			$arr["img"]="/".$url;
		}
		$this->Project_Model->update($arr,"id=".$id);
		$project_info = $this->Project_Model->get_one("id=".$id);
		$this->load->view('boss/projectedit',array("project_info"=>$project_info));
	}
	
	//首页-广告管理
	public function get_ad_list(){
		$page = isset($_GET['page'])?$_GET['page']:1;
		$this->load->model("Ad_Model");
		$where="deleted=0";
		$ad_list = $this->Ad_Model->get_list_p($where,"*"," id desc ",($page-1)*20,20);
		$total = $this->Ad_Model->getTotal($where);
		$this->load->view('boss/adlist',array("adlist"=>$ad_list,"page"=>$page,"page_size"=>ceil($total/20),
		));
	}
	
	public function add_ad(){
		$this->load->view('boss/add_ad');
	}
	
	public function add_adpost(){
		$url1 = isset($_POST['url'])?$_POST['url']:'';
		$order_num = isset($_POST['order_num'])?$_POST['order_num']:'';
		$address = isset($_POST['address'])?$_POST['address']:'';
	
		$this->load->model("Ad_Model");
		$string = $_FILES['file']['name'];
		$array = explode('.',$string);
		$ext=end($array);
		$url="";
		if($_FILES["file"]["tmp_name"]){
			$url="upload/fengm/" . time().rand(10000, 9999).".".$ext;
			move_uploaded_file($_FILES["file"]["tmp_name"],$url);
		}
		$arr = array(
				"url"=>$url1,
				"order_num"=>$order_num,
				"address"=>$address,
		);
		if($url){
			$arr["pic"]="/".$url;
		}
		$id = $this->Ad_Model->add($arr);
		$ad_info = $this->Ad_Model->get_one("id=".$id);
		$this->load->view('boss/ad_edit',array("ad_info"=>$ad_info));
	}
	
	public function edit_ad(){
		$id = isset($_GET['id'])?$_GET['id']:'';
		$this->load->model("Ad_Model");
		$ad_info = $this->Ad_Model->get_one("id=".$id);
		$this->load->view('boss/ad_edit',array("ad_info"=>$ad_info));
	}
	
	public function edit_adpost(){
		$id = isset($_POST['id'])?$_POST['id']:'';
		$url1 = isset($_POST['url'])?$_POST['url']:'';
		$order_num = isset($_POST['order_num'])?$_POST['order_num']:'';
		$address = isset($_POST['address'])?$_POST['address']:'';
	
		$this->load->model("Ad_Model");
		$string = $_FILES['file']['name'];
		$array = explode('.',$string);
		$ext=end($array);
		$url="";
		if($_FILES["file"]["tmp_name"]){
			$url="upload/fengm/" . time().rand(10000, 9999).".".$ext;
			move_uploaded_file($_FILES["file"]["tmp_name"],$url);
		}
		$arr = array(
				"url"=>$url1,
				"order_num"=>$order_num,
				"address"=>$address,
		);
		if($url){
			$arr["pic"]="/".$url;
		}
		$this->Ad_Model->update($arr,"id=".$id);
		$ad_info = $this->Ad_Model->get_one("id=".$id);
		$this->load->view('boss/ad_edit',array("ad_info"=>$ad_info));
	}
	
	public function deletead(){
		$id = isset($_GET['id'])?$_GET['id']:'';
		$this->load->model("Ad_Model");
		$arr = array(
				"deleted"=>1,
		);
		$this->Ad_Model->update($arr,'id='.$id);
		$page = 1;
		$this->load->model("Ad_Model");
		$where="deleted=0";
		$ad_list = $this->Ad_Model->get_list_p($where,"*"," id desc ",($page-1)*20,20);
		$total = $this->Ad_Model->getTotal($where);
		$this->load->view('boss/adlist',array("adlist"=>$ad_list,"page"=>$page,"page_size"=>ceil($total/20),
		));
	}
	
	public function project_list_type() {
		$page = isset($_GET['page'])?$_GET['page']:1;
		$type = isset($_GET['type'])?$_GET['type']:0;
		$style = isset($_GET['style'])?$_GET['style']:0;
		$little_name = isset($_GET['little_name'])?$_GET['little_name']:'';
		$this->load->model("Project_Model");
		$where=" b.deleted=0";
		if($type){
			$where = $where." and type=$type";
		}
		if($style){
			$where = $where." and style=$style";
		}
		if($little_name){
			$where = $where." and little_name='%$little_name%'";
		}
		$project_list = $this->Project_Model->get_list_p($where,"*","b.modify_date desc",($page-1)*20,20);
		$total = $this->Project_Model->get_list_p_t($where);
		$this->load->view('boss/project_typelist',array("project_list"=>$project_list,"page"=>$page,"page_size"=>ceil($total/20),
				"type"=>$type,
				"style"=>$style,
				"little_name"=>$little_name
		));
	}
	
	public function projecttypeadd(){
		$this->load->view("boss/projecttypeadd");
	}
	
	public function addprojecttypepost(){
		$type = isset($_POST['type'])?$_POST['type']:0;
		$style = isset($_POST['style'])?$_POST['style']:0;
		$project_ids = isset($_POST['project_ids'])?$_POST['project_ids']:0;
		$project_id_arr = explode(",",$project_ids);
		$this->load->model("Projecttype_Model");
		foreach ($project_id_arr as $k=>$v){
			$arr = array("type"=>$type,"style"=>$style,"project_id"=>$v);
			$id = $this->Projecttype_Model->add($arr);
		}
		$this->load->model("Project_Model");
		$where="and b.deleted=0";
		$page=0;
		$project_list = $this->Project_Model->get_list_p($where,"*","b.modify_date desc",($page-1)*20,20);
		$total = $this->Project_Model->get_list_p_t($where);
		$this->load->view('boss/project_typelist',array("project_list"=>$project_list,"page"=>$page,"page_size"=>ceil($total/20),
				"type"=>'',
				"style"=>'',
				"little_name"=>''
		));
	}
	
	public function deleteprojecttype(){
		$id = isset($_GET['id'])?$_GET['id']:'';
		$this->load->model("Projecttype_Model");
		$arr = array(
				"deleted"=>1,
		);
		$this->Projecttype_Model->update($arr,'id='.$id);
		$this->load->model("Project_Model");
		$where="b.deleted=0";
		$page=1;
		$project_list = $this->Project_Model->get_list_p($where,"*","b.modify_date desc",($page-1)*20,20);
		$total = $this->Project_Model->get_list_p_t($where);
		$this->load->view('boss/project_typelist',array("project_list"=>$project_list,"page"=>$page,"page_size"=>ceil($total/20),
				"type"=>'',
				"style"=>'',
				"little_name"=>''
		));
	}
	
	public function open_account_list(){
		$mobile = isset($_POST['mobile'])?$_POST['mobile']:0;
		$project_style = isset($_POST['project_style'])?$_POST['project_style']:0;
		$page = isset($_GET['page'])?$_GET['page']:1;
		$where="deleted=0";
		if($mobile){
			$where=$where." and mobile like '%".$mobile."%'";
		}
		if($project_style){
			$where=$where." and project_style =$project_style";
		}
		$this->load->model("Openaccount_Model");
		$list = $this->Openaccount_Model->get_list("*",$where,($page-1)*20,20);
		$total = $this->Openaccount_Model->getTotal($where);
		$this->load->view("boss/open_account_list",array("list"=>$list,"page"=>$page,"page_size"=>ceil($total/20),
				"mobile"=>$mobile,
				"project_style"=>$project_style,
		));
	}
	
	public function delete_open_account(){
		$id = $_GET['id']?$_GET['id']:'';
		$this->load->model("Openaccount_Model");
		$arr = array(
				"deleted"=>1,
		);
		$this->Openaccount_Model->update($arr,'id='.$id);
		$where="deleted=0";
		$page=1;
		$mobile = isset($_POST['mobile'])?$_POST['mobile']:0;
		$project_style = isset($_POST['project_style'])?$_POST['project_style']:0;
		$this->load->model("Openaccount_Model");
		$list = $this->Openaccount_Model->get_list("*",$where,($page-1)*20,20);
		$total = $this->Openaccount_Model->getTotal($where);
		$this->load->view("boss/open_account_list",array("list"=>$list,"page"=>$page,"page_size"=>ceil($total/20),
				"mobile"=>$mobile,
				"project_style"=>$project_style,
		));
	}
	
	public function add_open_account(){
		$this->load->view("boss/add_open_account");
	}
	
	public function add_open_account_post(){
		$mobile = isset($_POST['mobile'])?$_POST['mobile']:'';
		$project_style = isset($_POST['project_style'])?$_POST['project_style']:0;
		$email = isset($_POST['email'])?$_POST['email']:'';
		$name = isset($_POST['name'])?$_POST['name']:'';
		$this->load->model("Openaccount_Model");
		$arr = array(
				"mobile"=>$mobile,
				"project_style"=>$project_style,
				"email"=>$email,
				"name"=>$name,
		);
		$id = $this->Openaccount_Model->add($arr);
		$info = $this->Openaccount_Model->get_one("id=".$id);
		$this->load->view('boss/edit_open_account',array("info"=>$info));
	}
	
	public function edit_open_account(){
		$id = isset($_GET['id'])?$_GET['id']:'';
		$this->load->model("Openaccount_Model");
		$info = $this->Openaccount_Model->get_one("id=".$id);
		$this->load->view('boss/edit_open_account',array("info"=>$info));
	}
	
	public function edit_open_account_post(){
		$id = $_POST['id']?$_POST['id']:'';
		$mobile = isset($_POST['mobile'])?$_POST['mobile']:'';
		$project_style = isset($_POST['project_style'])?$_POST['project_style']:0;
		$email = isset($_POST['email'])?$_POST['email']:'';
		$name = isset($_POST['name'])?$_POST['name']:'';
		$this->load->model("Openaccount_Model");
		$arr=array(
				"mobile"=>$mobile,
				"project_style"=>$project_style,
				"email"=>$email,
				"name"=>$name
		);
		$this->Openaccount_Model->update($arr,'id='.$id);
		$info = $this->Openaccount_Model->get_one("id=".$id);
		$this->load->view('boss/edit_open_account',array("info"=>$info));
	}
	
}
